[translated by ikoma]

Debugging on ICE not on GDB
Shoji Ueda (KMC)
Tsuji
Kyoto Microcomputer


Embedded Linux Debugging with JTAG ICE

1. Introduction
  So far, only  available debuggers were GDB and KGDB.
  We have been studying how we can debug Linux.

2. Limitation of GDB
  Code running in kernel space is hard to debug with GDB.
  (c.f. Device drivers in user space would be easier to debug.)

  For instance, while breaking in driver, it is impossible to see memory of debugging target application.

3. Technical Issues
  * Relocatable objects
  * On demand paging
  * Virtual multiplexed spaces
   
4. Resolving Reloacation (Loadable Modules)

  We have hacked the loadble module for debugging
  Embed softwarebreak code in init.h macro
  Control transfers to ICE by executing softwarebreak at insmod
  Resolve .text at the transferred address

  Without ICE connected, there occurs exception and halts.
  In this method, switching between debugging time and otherwise is important.

5. Resolving Multiplexed Spaces

  Very tedious operation
  Keep tracking and tracking task_structs
  Not possible to rewrite a member in kernel as we like.
  Only information obtainable is which address of instruction was executed
  We modified kernel code so that we can get process information for postmortem examination.

6. Demonstration
  kernel 2.4

  Execute insmod, and .text, .data and .bss are displayed.
  Can debug loadable modules as usual.

  Breakpoint reached in kernel, and can see from which system call this was called. Not possible with GDB.

  Want to incorporate debugging support into kernel, without changing standard features

7. Tricks for Linux

  Attachment to running process
  Automatic loading of debug information
  Process support of function trace
  
8. On Open Source

  Because Linux is open source, it was possible to read info in kernel and to analyze it with ICE (such as incorporating extending code for ICE into kernel.)

9. Others

  ptrace is archaic API originating from unix era.
  New function seems to be expected now.

10. Q&A
  1) SMP supported?

    ICE can see two processors.
    It is not good for user to see two procesors. Should be seen as one.
    It is unknown on which processor to have halted. Need support for such case.
    These are hottest topic now.
    

  2) On ptrace interface

   It can be strange that /proc and ptrace coexist.
   Please post problems of ptrace onto CELF Wiki.
